/*
 * @Description  : 
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2022-03-09 14:05:33
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-03-09 15:18:38
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\sys-setting\\components\\note-management\\note-management.component.ts
 * Copyright (C) 2022 huzhenhong. All rights reserved.
 */
import { Component, OnInit, ViewChild } from '@angular/core';
import { STComponent, STColumn, STChange, STRequestOptions, STData } from '@delon/abc/st';
import { SFComponent, SFSchema } from '@delon/form';
import { SystemService } from '../../services/system.service';

@Component({
  selector: 'app-note-management',
  templateUrl: './note-management.component.html',
  styleUrls: ['../../../commom/less/box.less']
})
export class NoTeManagementComponent {
  @ViewChild('st', { static: true })
  st!: STComponent;
  @ViewChild('sf', { static: false })
  sf!: SFComponent;

  searchSchema: SFSchema = {
    properties: {
      cellphone: {
        type: 'string',
        title: '手机号',
        maxLength: 11,
        ui: { placeholder: '请输入' }
      }
    }
  };

  columns: STColumn[] = [
    {
      title: '序号',
      className: 'text-center',
      width: 40,
      format: (item: STData, col: STColumn, idx: number) => {
        return ((this.st.pi -1) * this.st.ps) + idx + 1 + ''
      } 
    },
    { title: '手机号', width: 100,className: 'text-center', index: 'cellphone' },
    {
      title: '发送时间',
      index: 'createTime',
      type: 'date',
      width: 150,
      className: 'text-center'
    },
    { title: '短信内容',width: 500, className: 'text-center', index: 'content',
    // format: (value) => {
    //   return JSON.parse(value?.templateParam)?.code
    // }
  },
  ];

  constructor(public service: SystemService) {
  }

  beforeReq = (requestOptions: STRequestOptions) => {
    if (this.sf) {
      Object.assign(requestOptions.body, { ...this.sf?.value });
    }
    return requestOptions;
  };



  /**
   * 重置表单
   */
  resetSF() {
    this.sf.reset();
  }
}
